#!/bin/bash
#global function

#function dbl {
#	value=$[ $value * 2 ]
#}

#read -p "enter a value" value
#dbl
#echo "the new value is : $value"

#array

#function testit {
#	echo "the parameters are : $@"
#	thisarray=$1
#	echo "the received array is ${thisarray[*]}"
#	}

#myarray=(1 3 5 7 78)
#echo "the original array is : ${myarray[*]}"
#testit $myarray

:<<!
function testit1 {
	local newarray
	newarray=('echo "$@"')
	echo "the new array value is : ${newarray[*]}"
	}

	myarray=(1 3 5 7 8 9 12)
	echo "the original array is ${myarray[*]}"
	testit1 ${myarray[*]}
!

function arraydblr {
	local origarray
	local newarray
	local elements
	local i
	origarray=($(echo "$@"))
	newarray=($(echo "$@"))
	elements=$[ $# - 1 ]
	for (( i = 0; i<= $elements; i++ )) {
		newarray[$i]=$[ ${origarray[$i]} * 2 ]
		}
		echo ${newarray[*]}
	}
	myarray=(1 4 6 78 2 6 78 8)
	echo "the original array is ${myarray[*]}"
	arg1=$(echo ${myarray[*]})
	result=($(arraydblr $arg1))
	echo "the new array is : ${result[*]}"
